package com.sky.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 尹稳健~
 * @version 1.0
 */
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // 主页跳转
        registry.addViewController("/main").setViewName("commons/commons");
//        registry.addViewController("/login").setViewName("login");
        // 登录成功跳转首页
        registry.addViewController("/index").setViewName("index");

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptors())
                .addPathPatterns("/**")
                .excludePathPatterns("/login","/","/css/**","/fonts/**",
                        "/images/**","/js/**","/lib/**",
                        "/swagger**/**","/webjars/**",
                        "/v3/**",
                        "/doc.html");
    }
}
